<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Bezier Animation</title>
    <script src="../dist/zrender.js"></script>
    <style>
        body {
            margin: 0;
        }
        #main {
            border: 1px solid #ccc;
        }
        #rect {
            position: absolute;
            z-index: 10;
            width: 100px;
            height: 100px;
            border: 1px solid #f00;
        }
    </style>
</head>
<body>
    <div id="rect">100x100</div>
    <div id="main" style="width:800px;height:400px;"></div>
    <script type="text/javascript">
        var canvas = document.createElement('canvas')
        canvas.width = 400;
        canvas.height = 400;
        var ctx = canvas.getContext('2d');
        var image = new Image();
        image.onload = function() {
            ctx.drawImage(image, 0, 0);

            var zr = zrender.init(document.getElementById('main'));
            var rect = new zrender.Rect({
                shape: {
                    x: 0,
                    y: 0,
                    width: 200,
                    height: 200
                },
                style: {
                    fill: {
                        image: canvas,
                        rotation: Math.PI / 6,
                        scaleX: 0.5,
                        x: 100
                    }
                }
            });
            zr.add(rect);
            zr.setBackgroundColor({
                image: image,
                repeat: 'no-repeat'
            });
        };
        image.src = './asset/test.png';

    </script>
</body>
</html>